package com.sc.nft.entity.vo.ecology;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.sc.nft.enums.UserEcologyExpenditureTypeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

@Data
public class UserEcologyExpenditureRecordPageVO {

    @ApiModelProperty(value = "类型 ECOLOGY_POINTS:生态燃料 EQUITY_PROPS:权益道具")
    private UserEcologyExpenditureTypeEnum type;

    @ApiModelProperty(value = "汇总收入")
    private String sumCount;

    @ApiModelProperty(value = "时间")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "标识")
    private Integer dateTime;

    @ApiModelProperty(value = "名称")
    private String typeName;

    public void setSumCount(BigDecimal sumCount) {
        if(type == UserEcologyExpenditureTypeEnum.ECOLOGY_POINTS){
            this.sumCount = sumCount.setScale(2,BigDecimal.ROUND_DOWN).toPlainString();
        }else{
            this.sumCount = sumCount.stripTrailingZeros().toPlainString();
        }
    }

    public void setTypeName(String typeName) {
        this.typeName = type.getDescription();
    }
}
